package com.imooc.sell.VO.pan;

import com.imooc.sell.dataobject.Remark;

import java.util.ArrayList;
import java.util.List;

/**
 * 后台访问评论列表的结果封装类
 */
@SuppressWarnings("unused")
public class RemarkRemark {

    public int mCode;

    public String msg;

    private ArrayList<ArrayList<Remark>> remarkremark = new ArrayList<>();

    public RemarkRemark() {
        this.mCode = 0;
        this.msg = "失败";
        this.remarkremark = null;
    }

    public RemarkRemark(int mCode, String msg, List<Remark> remarkList) {
        this.mCode = 1;
        this.msg = "成功";
        int i = 1;
        /*int i = list.size() - 1; i >= 0; i--*/
        for (Remark remark : remarkList) {
            if (i == 1) {
                ArrayList<Remark> remarks = new ArrayList<>();
                remarks.add(remark);
                remarkremark.add(remarks);

            } else {
                boolean isadd = false;
                for (List<Remark> rr : remarkremark) {
                    if (remark.getOrderId().equals(rr.get(0).getOrderId())) {
                        rr.add(remark);
                        isadd = true;
                    }
                }
                if (!isadd) {
                    ArrayList<Remark> remarks = new ArrayList<>();
                    remarks.add(remark);
                    remarkremark.add(remarks);
                }
            }
            i++;
        }
    }

    public int getmCode() {
        return mCode;
    }

    public void setmCode(int mCode) {
        this.mCode = mCode;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public ArrayList<ArrayList<Remark>> getRemarkremark() {
        return remarkremark;
    }

    public void setRemarkremark(ArrayList<ArrayList<Remark>> remarkremark) {
        this.remarkremark = remarkremark;
    }

    @Override
    public String toString() {
        String str = "";
        for (ArrayList<Remark> remarks : remarkremark) {
            str += "{";
            for (Remark remark : remarks) {
                str += remark.toString();
            }
            str += "}";
        }
        return "RemarkRemark{" +
                "mCode=" + mCode +
                ", msg='" + msg + '\'' +
                ", remarkremark=" + str +
                '}';
    }
}
